let app = getApp()
var stylecss = require('../../utils/stylecss.js');
Component({
    properties: {
      item: {
        type:Object
      }
      },
      data:{
      
      },
    lifetimes: {
        attached: function () {
           var postion=this.data.item.postion
           this.setData({
            postion:postion
           })
          var map_div_css=this.data.item.id+' .map_div';
          var item_image_css=this.data.item.id+' .item_image';
          var module_bg_css=this.data.item.id+' .module_bg';
          var info_item_wrap_css=this.data.item.id+' .info_item_wrap';
          this.setData({
              map_div_css:stylecss.css(map_div_css),
              item_image_css:stylecss.css(item_image_css),
              module_bg_css:stylecss.css(module_bg_css),
              info_item_wrap_css:stylecss.css(info_item_wrap_css),
          })
       }
      },
    methods: {
      btnTelPhone:function(){ 
        var phone =this.data.item.phone;
        wx.showModal({
          title: "是否要拨打这个电话？",
          content:phone,
          success: function(e) {
              e.confirm ?   wx.makePhoneCall({
                phoneNumber:phone,
                success:function(){
                  console.log('拨打成功')
                },
                fail:function(){
                  console.log('拨打失败')
                }
              })  : e.cancel && console.log("用户点击取消");
          }
      })
      },
      lookaddress:function(){
        var latitude =Number(this.data.postion.lat) 
        var longitude = Number(this.data.postion.lng)
        var name=this.data.postion.address
        var address=this.data.postion.city+this.data.postion.address
        wx.getLocation({
          type: 'gcj02',
          success: function (res) {
            wx.openLocation({
              latitude: latitude,
              longitude: longitude,
              name:name,
              address:address,
              scale: 28
            })
          }
        })
      }
    }
});
